<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%-- <%@ page import="java.text.SimpleDateFormat"%>  --%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>信息咨询</title>
<link rel="stylesheet" href="../common/kindeditor-4.1.10/themes/default/default.css" />
<script charset="utf-8" src="../common/kindeditor-4.1.10/kindeditor-min.js"></script>
<script charset="utf-8" src="../common/kindeditor-4.1.10/lang/zh_CN.js"></script>
<%@ include file="../../common/importLib.jsp" %>
<script type="text/javascript">
	/**
	 * 增删改查参数设置
	 */
	tablePageSize=5;
	tableTitle = "学校信息资讯";
	tableURL = getTimeURL("newsInfo/newsInfoList.do?");
	toolbarView = 4;
	tableColumns = [[{field:'ck',checkbox:true},
						{field:'opt',title:'操作',width:130,align:'center', rowspan:1,
						formatter:function(value,rowData,rowIndex){	
							var queryUrl = 'newsInfo/queryById.do?id=' + rowData.id;						
							return "<a title='修改' class='xxl_linkbutton' iconCls='icon-edit' href='javascript:datagridUpdate(\"" + queryUrl + "\")'>修改</a>";
						}
					},
	                {field:'id',title:'id',width:0,rowspan:1},	               
	                {field:'title',title:'标题',width:120,align:'center',rowspan:1},
					{field:'digest',title:'概要',width:220,align:'center',rowspan:1},
					{field:'userName',title:'发布人',width:70,align:'center',rowspan:1},
					{field:'publishDate',title:'发布时间',width:120,align:'center',rowspan:1},	
					{field:'disableFlag',title:'禁用状态',width:80,align:'center', rowspan:1,
						formatter:function(value,rowData,rowIndex){
							if(rowData.disableFlag == 0){
								return "<font color='green'>起用</font>";
							}else{
								return "<font color='red'>禁用</font>";
							}
						}
					}]];
	
	var addWidth = 900; //添加窗口宽度
	var addHeight = 500; //添加窗口高度
	var addTitle = "添加学校信息资讯"; //添加标题
	var updateWidth = 900; //修改窗口宽度
	var updateHeight = 500; //修改窗口高度
	var updateTitle = "修改学校信息资讯"; //修改标题
	var updateDisableFlagUri = "newsInfo/updateDisableFlag.do"; //禁用、起用记录
	var deleteUri = "newsInfo/deleteByIds.do"; //删除记录
	/**
	 * 初始化添加表单
	 */	
	function initAddForm(){
		    combobox_1("typeId", "newsInfo/newsTypeList.do",true);
			addFormProcess("title","信息",true);			
			baseFormValidator("title","标题",2,40); 	
			baseFormValidator("content","正文",1,10000);
			openPicUpload();
	}
	
	/**
	 * 初始化修改表单
	 */
	function initUpdateForm(jsonObject){
		updateFormProcess("titleUpdate","信息",true);
		$("#titleUpdate").val(jsonObject.title);
		$("#picNameUpdate").val(jsonObject.picName); 
		$("#uploadPicUpdate").attr("src",mrjyFile+"news/"+jsonObject.picName);
		$("#digestUpdate").val(jsonObject.digest);
		$("#contentUpdate").val(jsonObject.content); 
		$("#idUpdate").val(jsonObject.id);	
		openPicUploadUpdate();
		baseFormValidator("titleUpdate","标题",2,40); 	
		baseFormValidator("contentUpdate","正文",1,10000);
		editorUpdate.html(jsonObject.content);
	}
	
	
	/**
	 *打开照片上传组件
	 */
	function openPicUpload(){
		uploadOneFile("upload","/mrjy_file/common/util/upload.do","1000KB",100,30,"uploadMessage","backup/news/","picName","uploadPic");
	}
	/**
	 *打开修改照片上传组件
	 */
	function openPicUploadUpdate(){
		uploadOneFile("uploadUpdate","/mrjy_file/common/util/upload.do","1000KB",100,30,"uploadMessageUpdate","backup/news/","picNameUpdate","uploadPicUpdate");
	}
	
	
	
</script>
</head>
<body id="layout" class="easyui-layout" >
	<div region="center">
	<!-- datagrid信息表 -->
	<table id="datagrid_table"></table>
	</div>
	<!-- 添加记录 -->
	<div id="datagrid_add" style="display: none;">
		<form id="add_form" action="newsInfo/addNewsInfo.do" method="post">
			<input type="hidden" id="id" name="id">
			<input type="hidden" id="picName" name="picName" onclick='openPicUpload()'>
			<table align="center" style="margin: 0 auto" class="xxl_tb_1">
				<tbody>
					<tr>
						<td  class="">新闻标题：</td>
						<td ><input type="text" id="title" name="title"/></td>
						<td ><div id="titleTip" style="width:250px"></div></td>
					</tr>
					<tr>
						<td  class="">新闻类型：</td>
						<td colspan="2"><input type="text" id="typeId" name="typeId"/></td>
					</tr>
					<tr>
						<td class="xxl_td_2">新闻宣传图片：</td>
						<td >
							<input id='upload' type='file' name='uploadFile'/><span id='uploadMessage'></span>							
						</td>
						<td ><img style="height: 80px;width: 80px;" id ="uploadPic" src=""/><div style="color:red"> *照片后缀名为png，格式为200*200px</div></td>
					</tr>
					<tr>
						<td  class="">新闻概要：</td>
						<td ><input type="text" id="digest" name="digest"/></td>
						<td ><div id="digestTip" style="width:250px"></div></td>
					</tr>
					<tr>
						<td  class="xxl_td_1">新闻正文：</td>
						<td colspan="2">
						<textarea id="content" name="content" class="kindeditor" style="width:400px;height:300px;"></textarea>
						<div id="contentTip" style="width:250px"></div>
						</td>
					</tr>
					<tr>
						<td colspan="3" style="text-align: center">					
							<a class="easyui-linkbutton" iconCls="icon-ok" onclick="$('#add_form').submit();">添加</a>
							<a class="easyui-linkbutton" iconCls="icon-undo" onclick="document.getElementById('add_form').reset()">重置</a>
							<a class="easyui-linkbutton" iconCls="icon-cancel" onclick="$('#datagrid_add').window('close');">取消</a>
						</td>
					</tr>
					<tr height="20px;"></tr>
				</tbody>
			</table>
		</form>
	</div>
	
	<!--修改记录-->
	<div id="datagrid_update" style="display: none;">
		<form id="update_form" action="newsInfo/updateById.do" method="post">
			<input type="hidden" id="idUpdate" name="id">
			<input type="hidden" id="picNameUpdate" name="picName" onclick='openPicUploadUpdate()'>
			<table align="center" style="margin: 0 auto" class="xxl_tb_1">
				<tbody>
					<tr>
						<td  class="">标题：</td>
						<td ><input type="text" id="titleUpdate" name="title"/></td>
						<td ><div id="titleUpdateTip" style="width:250px"></div></td>
					</tr>
					<tr>
						<td class="xxl_td_2">新闻宣传图片：</td>
						<td >
							<input id='uploadUpdate' type='file' name='uploadFile'/><span id='uploadMessageUpdate'></span>							
						</td>
						<td ><img style="height: 80px;width: 80px;" id ="uploadPicUpdate" src=""/><div style="color:red"> *照片后缀名为png，格式为200*200px</div></td>
					</tr>
					<tr>
						<td  class="">新闻概要：</td>
						<td ><input type="text" id="digestUpdate" name="digest"/></td>
						<td ><div id="digestUpdateTip" style="width:250px"></div></td>
					</tr>
					<tr>
						<td  class="xxl_td_1">新闻正文：</td>
						<td colspan="2">
						<textarea id="contentUpdate" name="content"  class="kindeditor2" style="width:400px;height:300px;"></textarea>
						<div id="contentUpdateTip" style="width:250px"></div>
						</td>
					</tr>
					<tr>
						<td colspan="3" style="text-align: center">					
							<a class="easyui-linkbutton" iconCls="icon-ok" onclick="$('#update_form').submit();">修改</a>
							<a class="easyui-linkbutton" iconCls="icon-cancel" onclick="$('#datagrid_update').window('close');">取消</a>
						</td>
					</tr>
					<tr height="20px;"></tr>
				</tbody>
			</table>
		</form>
	</div>
</body>
</html>